/*
 * Copyright (C) 2022 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import BeaconConsumer from '../BeaconConsumer';
import BeaconManager from '../BeaconManager';
import MonitorNotifier from '../MonitorNotifier';
import Region from '../Region';
//import LogManager from '../logging/LogManager';

class RegionBootstrap{
//  protected readonly TAG:string="AppStarter";
//  private beaconManager:BeaconManager;
//  private monitorNotifier:MonitorNotifier;
//  private context;
//  private regions:Array<Region>;
//  private disabled:boolean= false;
//  private beaconConsumer:BeaconConsumer;
//  private serviceConnected:boolean=false;
//
//  constructor(monitorNotifier?:MonitorNotifier,region?:Region,regions?:Array<Region>,application?){
//    if(monitorNotifier!="" && region!=""){
//      this.monitorNotifier=monitorNotifier;
//      this.regions=new Array<Region>();
//      this.regions.push(region);
//
//      this.beaconManager=BeaconManager.getInstanceForApplication();
//      this.beaconConsumer=new InternalBeaconConsumer();
//      if(this.beaconManager.isBackgroundModeUninitialized()){
//        this.beaconManager.setBackgroundMode(true);
//      }
//      this.beaconManager.bind(this.beaconConsumer);
//    }else if(monitorNotifier!="" && regions!=""){
//      this.monitorNotifier = monitorNotifier;
//      this.regions = regions;
//
//      this.beaconManager=BeaconManager.getInstanceForApplication();
//      this.beaconConsumer=new InternalBeaconConsumer();
//      if(this.beaconManager.isBackgroundModeUninitialized()){
//        this.beaconManager.setBackgroundMode(true);
//      }
//      this.beaconManager.bind(this.beaconConsumer);
//    }else if(application!="" && region!=""){
//      this.regions = regions;
//      this.monitorNotifier = application;
//      this.beaconManager=BeaconManager.getInstanceForApplication();
//      this.beaconConsumer=new InternalBeaconConsumer();
//      if(this.beaconManager.isBackgroundModeUninitialized()){
//        this.beaconManager.setBackgroundMode(true);
//      }
//      this.beaconManager.bind(this.beaconConsumer);
//    }
//  }
//
//  public disable(){
//    if (this.disabled) {
//      return;
//    }
//    this.disabled = true;
//    try{
//      this.regions.forEach(region=>{
//        this.beaconManager.stopMonitoringBeaconsInRegion(region);
//      })
//    }catch(e){
//      console.log(e,this.TAG,"Can't stop bootstrap regions");
//    }
//    this.beaconManager.unbind(this.beaconConsumer);
//  }
//
//  public addRegion(region:Region){
//    if(this.regions.indexOf(region)==-1){
//      if(this.serviceConnected){
//        try{
//          this.beaconManager.startMonitoringBeaconsInRegion(region);
//        }catch(e){
//          console.error(e,this.TAG,"Can't add bootstrap region");
//        }
//      }else{
//        console.error(this.TAG, "Adding a region: service not yet Connected");
//      }
//      this.regions.push(region);
//    }
//  }
//
//  public removeRegion(region:Region){
//    if(this.regions.indexOf(region)>=0){
//      if(this.serviceConnected){
//        try{
//          this.beaconManager.stopMonitoringBeaconsInRegion(region);
//        }catch(e){
//          console.error(e, this.TAG, "Can't stop bootstrap region")
//        }
//      }else{
//        console.error(this.TAG, "Removing a region: service not yet Connected")
//      }
//      this.regions.splice(this.regions.indexOf(region),1);
//    }
//  }
}

//class InternalBeaconConsumer implements BeaconConsumer{
//  private serviceIntent;
//  public onBeaconServiceConnect(){
//    console.log("Activating background region monitoring");
//    this.beaconManager.addMonitorNotifier(this.monitorNotifier);
//    this.serviceConnected=true;
//    try{
//      this.regions.forEach(region=>{
//        console.log("Background region monitoring activated for region %s", region);
//        this.beaconManager.startMonitoringBeaconsInRegion(region);
//      })
//    }catch(e){
//        console.error("Can't set up bootstrap regions");
//    }
//
//  }
//
//  public bindService(intent: Map<string, any>,connection: any):boolean{
//    return;
//  }
//
//  public unbindService(connection: any): void { }
//}